package com.pan.test.socket.example04;

import java.io.*;
import java.net.InetAddress;
import java.net.Socket;

public class Client04 {
    public static void main(String[] args) throws IOException {
        Socket socket = new Socket(InetAddress.getByName("192.168.31.43"),11451);
        OutputStream outputStream = socket.getOutputStream();
        String question = "姓名？";
        BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(outputStream));
        writer.write(question);
        writer.newLine();
        writer.flush();
        socket.shutdownOutput();


        InputStream inputStream = socket.getInputStream();
        BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream) );
        String answer = reader.readLine();
        System.out.println(answer);


        reader.close();
        inputStream.close();
        writer.close();
        outputStream.close();
        socket.close();

    }
}
